package com.swh.service.Impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.swh.dao.SysResourceDao;
import com.swh.entity.QualificationCondition;
import com.swh.entity.SysResource;
import com.swh.service.SysResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Author: swh
 * @Description:
 * @Date: 2020/12/14 14:46
 * @Version: 1.0
 */
@Service
public class SysResourceServiceImpl extends BaseServiceImpl<SysResource> implements SysResourceService {

    @Autowired
    public SysResourceServiceImpl(SysResourceDao sysResourceDao) {
        super(sysResourceDao);
    }

    @Autowired
    private SysResourceDao sysResourceDao;



    @Override
    public PageInfo<Map> selectPage(Integer pageNum, Integer pageSize, QualificationCondition condition) {
        PageHelper.startPage(pageNum, pageSize);
        List<Map> list = sysResourceDao.selectPage((pageNum - 1) * pageSize, pageSize, condition);
        return new PageInfo<>(list);
    }

    @Override
    public List<SysResource> findAll() {
        return sysResourceDao.findAll();
    }

    @Override
    @Cacheable(cacheNames = "resourceCache", key = "'com.swh.service.Impl.SysResourceServiceImpl:selectResources'")
    public List<SysResource> selectResources() {
        return sysResourceDao.selectResources();
    }

    @Override
    public List<SysResource> selectByUid(long uid) {
        return sysResourceDao.selectByUid(uid);
    }
}
